﻿package Chapter06;
import java.util.ArrayList;

public class DotCom {
	// 實體變數
	private ArrayList<String> locations = new ArrayList<String>(); 
	private String name = "";
	private int index = 0;

	// 方法
	void setLocationCells(ArrayList<String> locs) {
		locations = locs;
		return;
	}
	
	void setName(String s) {
		name = s;
	}
	
	void setIndex(int i) {
		index = i;
	}
	
	boolean hasPlace(String p) {
		return locations.contains(p);
	}
	
	String getName() {
		return name;
	}
	
	int getIndex() {
		return index;
	}

	String checkYourself(String strGuess) {
		if (isHit(strGuess)) {
			removeCell(strGuess);
			if (locations.isEmpty()) {
				return "kill";
			}
			return "hit";
		}

		return "miss";
	}
	
	boolean isHit(String loc) {
		return locations.contains(loc);
	}
	
	void removeCell(String cellId) {
		//Integer cellIndex = Integer.parseInt(cellId);
		locations.remove(cellId);
	}
}
